package com.eostoken.eos_wallet.ui.fragment;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.RecyclerView;

import com.blankj.utilcode.util.StringUtils;
import com.eostoken.eos_wallet.R;
import com.eostoken.eos_wallet.base.BaseFragment;
import com.fredy.mvp.BasePresenter;
import com.fredy.mvp.BaseView;
import com.fredy.mvp.Model;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.pullLayout.QMUIPullLayout;
import com.qmuiteam.qmui.widget.pullLayout.QMUIPullLoadMoreView;
import com.qmuiteam.qmui.widget.pullLayout.QMUIPullRefreshView;
import com.qmuiteam.qmui.widget.tab.QMUITabBuilder;
import com.qmuiteam.qmui.widget.tab.QMUITabIndicator;
import com.qmuiteam.qmui.widget.tab.QMUITabSegment;

import butterknife.BindView;

public class VoteFragment extends BaseFragment {

    @BindView(R.id.topBar)
    QMUITopBarLayout topBar;
    @BindView(R.id.searchView)
    SearchView searchView;
    @BindView(R.id.tabSegment)
    QMUITabSegment mTabSegment;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.refreshView)
    QMUIPullRefreshView refreshView;
    @BindView(R.id.loadMoreView)
    QMUIPullLoadMoreView loadMoreView;
    @BindView(R.id.pull_layout)
    QMUIPullLayout pullLayout;
    @BindView(R.id.selectedNodeBtn)
    Button selectedNodeBtn;
    @BindView(R.id.voteBtn)
    Button voteBtn;
    @BindView(R.id.bottomBtnLayout)
    LinearLayout bottomBtnLayout;


    private String[] arr;
    private int classify;

    @Override
    protected int getContentLayout() {
        return R.layout.fragment_vote;
    }

    @Override
    protected void initData() {
        arr = new String[]{getString(R.string.str_node_vote), getString(R.string.str_node_rankings)};
    }

    @Override
    protected void initView(View contentView) {
        topBar.setTitle(StringUtils.getString(R.string.str_vote));
        topBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popOrFinish();
            }
        });
        initTabAndPager();
    }

    private void initTabAndPager() {
        QMUITabBuilder builder = mTabSegment.tabBuilder().setGravity(Gravity.CENTER);
        for (int i = 0; i < arr.length; i++) {
            mTabSegment.addTab(builder.setText(arr[i]).build(getActivity()));
        }
        mTabSegment.setMode(QMUITabSegment.MODE_FIXED);
        int indicatorHeight = QMUIDisplayHelper.dp2px(getActivity(), 2);
        mTabSegment.setIndicator(new QMUITabIndicator(indicatorHeight, false, false));
        mTabSegment.selectTab(0);
        mTabSegment.addOnTabSelectedListener(new QMUITabSegment.OnTabSelectedListener() {
            @Override
            public void onTabSelected(int index) {
                classify = index;
                switch (classify) {
                    case 1:
                        break;
                    default:
                        break;
                }

            }

            @Override
            public void onTabUnselected(int index) {

            }

            @Override
            public void onTabReselected(int index) {
            }

            @Override
            public void onDoubleTap(int index) {
                mTabSegment.clearSignCountView(index);
            }
        });
    }

    @Override
    public Model createModel() {
        return null;
    }

    @Override
    public BaseView createView() {
        return null;
    }

    @Override
    public BasePresenter createPresenter() {
        return null;
    }

    @Override
    public void finishRefresh() {

    }
}
